package org.example;

public class StringExtractor {
    private enum State {
        NORMAL,TRANSFER
    }

    public List<String> extractStrings(String source) {
        List<String> strings = new ArrayList<>();
        StringBuilder currentString = new StringBuilder();
        State state = State.NORMAL;

        for (char c : source.toCharArray()) {
            switch (state) {
                case NORMAL:
                    if (c == '\') {
                    state = State.TRANSFER;
            } else if (c == '"') {
                if (currentString.length() > 0) {
                    strings.add(currentString.toString());
                    currentString = new StringBuilder();
                }
            } else {
                currentString.append(c);
            }
            break;
            case TRANSFER:
                currentString.append(c);
                state = State.NORMAL;
                break;
        }
    }

        return strings;
}
}
